package roadsuggester.main;

import roadsuggester.db.UserLocationsDatabase.UserLocation;
import android.app.Application;
import android.content.Context;
import android.location.Location;


//Calculates proximity to destination.
public class DestinationProximityCalculator
{
	public final int REACH_PROXIMITY=50;		//When N meters close to destination, assume you have reached.
	private Context context;
	private Location destination;
	
	

	public DestinationProximityCalculator(Context context, Location destination)
	{
		this.context=context;
		this.destination=destination;
	}

	public DestinationProximityCalculator(Context context, UserLocation destination)
	{
		this(context,destination.latitude,destination.longitude);
	}
	
	public DestinationProximityCalculator(Context context, double destinationLattitude, double destinationLongitude)
	{
		Location destination=new Location("");
		destination.setLatitude(destinationLattitude);
		destination.setLongitude(destinationLongitude);
		
		this.context=context;
		this.destination=destination;
		
	}

	public boolean hasReachedDestination(Location currentLocation)
	{
		//TODO: record the locations so that only when the user is close to the destination for N seconds it returns true
		return REACH_PROXIMITY>currentLocation.distanceTo(destination);
	}

}
